{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "import sys\n",
    "import os\n",
    "CURRENT_DIR = os.path.split(os.path.abspath(\"./\"))[0]  # 当前目录\n",
    "sys.path.append(CURRENT_DIR)\n",
    "import predict_ner.predict_conv as ner\n",
    "import predict_DM.predict_DM as DM\n",
    "import os\n",
    "import tensorflow as tf\n",
    "import dialogue_pipeline.get_state as trackers"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "# import re\n",
    "# from State_Form import *\n",
    "# device_name = 'AC|Lamp|Fan'\n",
    "# state_dic = dic"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "def pipeline(text):\n",
    "    intent,entities,entities_dic = ner.predict(text)\n",
    "    tracker,_ = trackers.get_DM_input([intent,entities_dic])\n",
    "    action  = DM.predict(tracker)\n",
    "    print('action : ',action)\n",
    "    tracker,_= trackers.get_DM_input([intent,entities_dic,[action]])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "intent:Control-Fan_Timing \n",
      " slot:{'device': '风扇', 'operation': '关闭', 'time': '一小时'}\n",
      "　text: [['PAD'], ['operation', 'time', 'device'], ['Control-Fan_Timing']] \n",
      " action:actiming_form \n",
      " \n",
      "action :  actiming_form\n"
     ]
    }
   ],
   "source": [
    "pipeline('一小时后关闭风扇')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": true,
    "jupyter": {
     "outputs_hidden": true
    },
    "tags": []
   },
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'intent' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[0;32m<ipython-input-11-0e5fca91081b>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mstate_dic\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mtrackers\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mFrom_Reset\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mintent\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[0;31mNameError\u001b[0m: name 'intent' is not defined"
     ]
    }
   ],
   "source": [
    "state_dic = trackers.From_Reset(intent)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
